package com.felix.ocoupon.converter;

import com.felix.ocoupon.constant.ProductLine;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

/**
 * @author hsufelix
 * @email hsufelix@yeah.net
 * @Date 2020/11/12
 * ProductLineConverter
 * 枚举转换器
 */
@Converter
public class ProductLineConverter implements
        AttributeConverter<ProductLine, Integer> {

    @Override
    public Integer convertToDatabaseColumn(ProductLine productLine) {
        return productLine.getCode();
    }

    @Override
    public ProductLine convertToEntityAttribute(Integer code) {
        return ProductLine.of(code);
    }
}
